<?php

namespace api\controllers;


use api\components\BaseController;
use common\models\User;
use Yii;

/**
 * 授权登录
 * Class LoginController
 * @package api\controllers
 */
class LoginController extends BaseController
{
    /**
     * 登录
     * @return array
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     */
    public function actionLogin()
    {
        $params = Yii::$app->request->post();
        $code = $params['code'] ?? '';
        $rawData = $params['data'] ?? '';
        $sub = (int)$params['invit_code'] ?? '';
        $model = new User();
        return $model->login($code,$rawData,self::$jwtId,$sub);
    }
}